|
|
|
|
|
|
|
These knot values are used to create open-ended curves like the ones shown in Figure 11.22. In Visual Basic, you can easily write a function to compute these knot values. |
|
|
|
 |
|
|
|
|
' Return the ith knot value. Private Function Knot(ByVal i As Integer) As Integer
If i < Kvalue Then
Knot = 0
ElseIf i <= MaxPt Then
Knot = i - Kvalue + 1
Else
Knot = MaxPt - Kvalue + 2
End If
End Function |
|
|
|
|
|
|
|
|
Using the knot values, you can define the B-spline blending functions recursively. |
|
|
|
 |
|
|
|
|
Bi,1(t) =
1 if Knot(i) <= t < Knot(i + 1)
1 if Knot(i) <= t < Knot(i + 1) and t = N - K + 2
0 otherwise
Bi,k(t) = (t - Knot(i)) * Bi,k-1(t) / (Knot(i + k - 1) - Knot(i)) +
(Knot(i + k) - t) * Bi+1,k-1(t) / (Knot(i + k) - Knot (i + 1) |
|
|
|
|
|
|
|
|
If the denominator of either of the fractions is zero, that fraction is defined to have value zero. |
|
|
|
|
|
|
|
|
While these equations are fairly confusing, writing a Visual Basic function to compute the blending function values is not hard. |
|
|
|
 |
|
|
|
|
' Recursively compute the blending function. Private Function Blend(ByVal i As Integer, _
ByVal k As Integer, ByVal t As Single) As Single
Dim numer As Single
Dim denom As Single
Dim value1 As Single
Dim value2 As Single
' Base case for the recursion. If k = 1 Then
If (Knot(i) <= t) And (t < Knot(i + 1)) Then
Blend = 1
ElseIf (t = MaxT) And (Knot(i) <= t) And _
(t <= Knot(i + 1)) _
Then
Blend = 1
Else
Blend = 0
End If |
|
|
|
|
|